$().ready(function() {
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
		save();
	}
});

let submit = false;

function save() {
	if(submit){
		return;
	}

	if($("#sTime").val() == ''){
		layer.msg("请选择入账月份");
		return;
	}
	if($("#settlemantPlatform").val() == ''){
		layer.msg("请选择入账平台");
		return;
	}
	submit = true;

	$.ajax({
		cache : true,
		type : "POST",
		url : ctxPath+"/wallpaper/settlemenbill/addWalletInfo",
		data : {
			sTime:$("#sTime").val(),
			settlemantPlatform:$("#settlemantPlatform").val()
		},
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			submit = false;
			if (data.code == 0) {

				parent.layer.msg("入账成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.msg(data.msg)
			}

		},error:function (){
			submit = false;
		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			sTime : {
				required : true
			},
			settlemantPlatform : {
				required : true
			}
		},
		messages : {
			sTime : {
				required : icon + "请选择日账月份"
			},
			settlemantPlatform : {
				required : icon + "请选择入账平台"
			}
		}
	})
}